/*
 * RootSearch.h
 *
 *  Created on: 14.04.2011
 *      Author: ed
 */

#ifndef ROOTSEARCH_H_
#define ROOTSEARCH_H_
#include "IExperimentalVolume.hh"
#include "G4RunManager.hh"
#include "Sample.hh"
#include "stack"
class IExperimentalVolume;
class G4RunManager;
class Sample;
using namespace std;
class RootSearch
{
public:
	RootSearch(IExperimentalVolume *Volume,G4RunManager *RunManager);
	virtual ~RootSearch();
	G4double Root(G4double lCExp,G4double lSc,G4double delta,G4double l,G4double r);
	static G4double GetZero(Sample* sl, Sample* sr,G4double lCExp);
	static inline G4double GetK(const Sample* sl,const Sample* sr)
	{
		return (sr->GetLC() - sl->GetLC())/(sr->GetLAbs() - sl->GetLAbs());
	}
	void PumpSample(Sample* s, int n)
	{
		vol->SetLAbs(s->GetLAbs());
		for(int i = 0;i<n;i++)
		{
			runManager->BeamOn(1);
			s->AddExperiment(vol->GetLightCollection());
		}
	}
private:
	IExperimentalVolume *vol;
	G4RunManager *runManager;
	G4int antiWrongDecisionFactor;
	stack<Sample*> *left,*right;
	G4int missCount;
};

#endif /* ROOTSEARCH_H_ */
